package com.cqwu.util;

import java.util.List;

/**
 * 分页辅助工具类
 * @author LK
 *
 */
public class PageBean<T> {
	
	private List<T> list;         
	private int pageSize = 3;   //每页显示的记录条数
	private int currentPage = 1;//当前显示的页码
	private int totalPage;      //总共的页数
	private int startNum;       //起始页码
	private int startRecord;    //从第几条记录开始取数据
	private int endNum;         //结束页码 
	private String requestURI;  //
	
	public PageBean(){}
	
	//param：页码, 总记录数
	public PageBean(int startNum,long totalRecord){
		this.startNum = startNum==1?startNum+1:startNum;
		this.currentPage = startNum;
		//计算 总页数，开始页码和结束页码
		if(totalRecord % this.pageSize ==0){
			this.totalPage = (int) (totalRecord / this.pageSize);
		}else{
			this.totalPage = (int) (totalRecord / this.pageSize) + 1;
		}
		this.endNum = this.startNum + this.pageSize-1;
		//如果结束页码大于总页数
		if(this.endNum>this.totalPage-1){
			//结束页码为总页数
			this.endNum = this.totalPage-1;
			//开始页码为 总页数 - 页面大小
			this.startNum =  (this.totalPage-this.pageSize);
		}
	}
	
	public List<T> getList() {
		return list;
	}
	public void setList(List<T> list) {
		this.list = list;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getStartRecord() {
		return startRecord;
	}

	public void setStartRecord(int startRecord) {
		this.startRecord = startRecord;
	}

	public int getStartNum() {
		return startNum;
	}
	
	public void setStartNum(int startNum) {
		this.startNum = startNum;
	}
	public void setEndNum(int endNum) {
		this.endNum = endNum;
	}
	public int getEndNum() {
		return endNum;
	}

	public String getRequestURI() {
		return requestURI;
	}

	public void setRequestURI(String requestURI) {
		this.requestURI = requestURI;
	}

}


